package com.situ.web.demo;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import org.junit.Test;
import com.situ.web.entity.Student;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLBoundFault;

public class Demo {

	@Test
	public void test1() {
		List<Student> list = new ArrayList<Student>();
		//ArrayList<Student> list = new ArrayList<Student>();
		Student student1 = new Student(1, "张三1", 20, "男");
		Student student2 = new Student(2, "张三2", 20, "男");
		Student student3 = new Student(3, "张三3", 20, "男");
		list.add(student1);
		list.add(student2);
		list.add(student3);
		list.add(student1);
		for (Student student : list) {
			System.out.println(student);
		}
		System.out.println("==================");
		Set<Student> set = new HashSet<Student>();
		//HashSet<Student> set = new HashSet<Student>();
		set.add(student1);
		set.add(student2);
		set.add(student3);
		set.add(student1);
		for (Student student : set) {
			System.out.println(student);
		}
	}
	
	@Test
	public void test2() {
		//  key  	value
		//  CN   	中华人民共和国
		//  US	       美利坚合众国
		Map<String, String> map = new HashMap<String, String>();
		map.put("CN", "中华人民共和国");
		map.put("US", "美利坚合众国");
		
		// 根据key，找到这个key对应的value值
		String value1 = map.get("CN");
		System.out.println(value1);//中华人民共和国
		String value2 = map.get("US");
		System.out.println(value2);//美利坚合众国
		
		// Map遍历
		// Entry 是对key-value的封装
	    Set<Entry<String, String>> set	= map.entrySet();
	    for (Entry<String, String> entry : set) {
			String key = entry.getKey();
			String value = entry.getValue();
			System.out.println("key: " + key + ", value:" + value);
		}
	    
	}
	
	
	
	
	
}
